#include<iostream>
#include<algorithm>
using namespace std;
string madd(string a,string b){
    int jinwei=0;
    string res="";
    for(int i=a.length()-1;i>=0;i--){
        int r=a[i]-'0'+b[i]-'0'+jinwei;
        jinwei=r/10;
        r=r%10;
        res+=r+'0';
    }
    if(jinwei>0)
        res+=jinwei+'0';
    reverse(res.begin(),res.end());
    return res;
}
int main(){
    string N;
    int K;
    cin>>N>>K;
    string rres;
    rres.assign(N.rbegin(),N.rend());
    if(N==rres){
        cout<<N<<endl;
        cout<<0<<endl;
        return 0;
    }

    int step=1;
    string res=N;
    while(step<=K){
        res = madd(res,rres);
        rres.assign(res.rbegin(),res.rend());
        //cout<<"res:"<<res<<" rres:"<<rres<<endl;
        if(res==rres){
            cout<<res<<endl;
            cout<<step<<endl;
            break;
        }
        step++;
    }
    if(step>K){
        cout<<res<<endl;
        cout<<K<<endl;
    }
    return 0;
}
